@(openProjects: List[models.domain.Project])
@main(title = "Næstu skil") {

    <link rel="stylesheet" href="/public/stylesheets/exams.css">

    <div class="container">

        <div class="row">
            <div class="span12">
                <h3>Næstu skil</h3>
                    <table class="table table-striped" cellpadding="0" cellspacing="0" border="0" class="display">
                        <thead>
                            <tr>
                                <th> Verkefni </th>
                                <th> Fag </th>
                                <th> Lagt fyrir </th>
                                <th> Skilafrestur </th>
                                <th> Skilað/Óskilað </th>
                                <th> Vægi </th>
                                <th> Einkunn </th>
                            </tr>
                        </thead>
                        <tbody>
                            @for(project <- openProjects) {
                                @if(project.getHandedIn == true){
                                    <tr class="success">
                                    <td> <a href="studentOneProject/@project.getVerkefni_id"/> @project.getName </td>
                                    <td> @project.getCourse </td>
                                    <td> @project.getbeginDate() </td>
                                    <td id="d@project.getVerkefni_id()"> @project.getHandInDate </td>
                                        @if(project.getHandedIn == true) {
                                            <td> Skilað </td>
                                        }
                                        @if(project.getHandedIn == false) {
                                            <td> Óskilað </td>
                                        }
                                    <td> @(project.getWeight) % </td>
                                        @if(project.getGrade == 20) {
                                            <td> - </td>
                                        }
                                        @if(project.getGrade < 20) {
                                            <td> @project.getGrade </td>
                                        }

                                    </tr>
                                }else{
                                    <tr id="d@project.getVerkefni_id()">
                                        <td> <a href="studentOneProject/@project.getVerkefni_id"/> @project.getName </td>
                                        <td> @project.getCourse </td>
                                        <td> @project.getbeginDate() </td>
                                        <td id="d@project.getVerkefni_id()"> @project.getHandInDate </td>
                                        @if(project.getHandedIn == true) {
                                            <td> Skilað </td>
                                        }
                                        @if(project.getHandedIn == false) {
                                            <td> Óskilað </td>
                                        }
                                        <td> @(project.getWeight) % </td>
                                        @if(project.getGrade == 20) {
                                            <td> - </td>
                                        }
                                        @if(project.getGrade < 20) {
                                            <td> @project.getGrade </td>
                                        }

                                    </tr>
                                }
                            }
                        </tbody>
                     </table>
            </div>
        </div>
    </div>


    <script language="javascript" type="text/javascript">
        @for(project <- openProjects){

                var tumi = "@{project.getHandInDate}";
                var datearray = tumi.split(".");
                var yeararray = datearray[2].split(" ");
                var timinn = yeararray[0] + '/' + datearray[1] + '/' + datearray[0] + ' ' + yeararray[1];

                var date = new Date(timinn);
                //var description = "Skiladagur";
                var now = new Date();
                var diff = date.getTime() - now.getTime();
                var days = Math.floor(diff / (1000 * 60 * 60 * 24));
                var element = document.getElementById("d@project.getVerkefni_id()");

                if (days < 2) {
                element.className='error';
                }
                if(days == 2 || days == 3){
                element.className='warning';
                }
        }
    </script>

}